package cn.kmia.hrm.service.system;

import cn.kmia.hrm.pojo.system.Permission;
import cn.kmia.hrm.service.BaseService;
import org.nutz.dao.Cnd;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.log.Log;
import org.nutz.log.Logs;

import java.util.List;

/**
 * @项目：java_baggage_led
 * @作者：4K
 * @描述：权限信息服务类
 * @日期：created in 16:45 2018/1/30
 */
@IocBean
public class PermissionService extends BaseService {

    private static final Log log = Logs.get();

    /**
     * 查询权限，不分页
     *
     * @param name 名称
     * @return
     */
    public List<Permission> query(String name) {
        Cnd cnd = Cnd.where("1", "=", 1);
        if (!Strings.isBlank(name) && !"null".equals(name)) {
            cnd.and("name", "like", "%" + name + "%");
        }
        return dao.query(Permission.class, cnd);
    }

    /**
     * 获取权限
     *
     * @param id
     * @return
     */
    public Permission getPower(int id) {
        return dao.fetch(Permission.class, Cnd.where("id", "=", id));
    }
}
